﻿using Models.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yymbDAL
{
    public class Other_users
    {    
        /// <summary>
        /// 其他用户个人简介
        /// </summary>
        /// <returns></returns>
        public Information Oth_use_Info(int id)
        {
            using (yymbDBEntities db = new yymbDBEntities())
            {
                return db.Information.Include("Personality_tag").SingleOrDefault(n => n.UserID == id);
            }
        }
        /// <summary>
        /// 其他用户微博
        /// </summary>
        /// <returns></returns>
        public List<Microblog> Oth_use_mibl(int id)
        {
            using (yymbDBEntities db = new yymbDBEntities())
            {
                return db.Microblog.Include("Information").Where(n => n.UserID == id).OrderByDescending(n => n.Release_time).ToList();
                    
            }
        }
        /// <summary>
        /// 其他用户关注数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Oth_use_atte(int id)
        {
            using (yymbDBEntities db = new yymbDBEntities())
            {
                return db.User_rs.Where(n => n.UserID == id).Count();
                
            }
        }
        /// <summary>
        /// 其他用户粉丝数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Oth_use_fans(int id)
        {
            using (yymbDBEntities db = new yymbDBEntities())
            {
                return db.User_rs.Where(n => n.Use_UserID == id).Count();
               
            }
        }
        /// <summary>
        /// 查询其他用户关注的人
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List<User_rs> GetUserFollow(int id)
        {
            using (yymbDBEntities db=new yymbDBEntities())
            {
                return db.User_rs.Include("Information1").Where(u => u.UserID == id).ToList();
           
            }
        }
        /// <summary>
        /// 其他用户微博数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Oth_use_mibls(int id)
        {
            using (yymbDBEntities db = new yymbDBEntities())
            {
                return db.Microblog.Where(n => n.UserID == id).Count();
                
            }
        }
        /// <summary>
        /// 其他用户的总微博数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int SumWB(int id)
        {
            using (yymbDBEntities db=new yymbDBEntities())
            {
                return db.Microblog.Where(n => n.UserID == id).Count();
            }
        }
    }
}
